<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
    <!--    <script src="https://cdn.staticfile.net/vue/2.2.2/vue.min.js"></script>-->
    <!--前后端请求-->
    <script src="js/axio.js"></script>
    <style>


        #Box {
            width: 400px;
            height: 80px;
            margin: 0 auto;
            margin-top: 30px;
        }

        #Box #input1 {
            width: 300px;
            height: 25px;
            margin-left: 50px;
            border-radius: 5px 5px 5px 5px;
        }

        #Box #input2 {
            width: 300px;
            height: 25px;
            margin-top: 5px;
            margin-left: 50px;
            border-radius: 5px 5px 5px 5px;
        }

        #Box button {
            background-color: papayawhip;
            border-radius: 5px 0 5px 0;
            margin-top: 5px;
            margin-left: 200px;
        }
        .titlemax{
            width: 250px;
            height: 20px;
            margin: 0 auto;
            margin-top: 100px;
        }
        .titlemax a{
            font-size: 30px;
            font-family: "楷体";
            font-weight: bolder;
        }
    </style>
</head>
<body>
<div class="titlemax">
    <a class="title">员工管理登陆系统</a>
</div>
<div id="Box">
    <form @submit.prevent="login">
        <input type="text" v-model="form.username" id="input1"><br>
        <input type="password" v-model="form.password" id="input2"><br>
        <button>登录</button>
    </form>
</div>
<script>
    new Vue({
        el: "#Box",
        data: {
            form: {
                username: '',
                password: ''
            }
        },
        methods: {
            login() {
                axios.post("http://localhost:8080/login", this.form).then(
                    response => {
                        if (response.data.data != null) {
                            window.location.href = "html2.html"
                        } else {
                            alert("用户名或密码错误!");
                        }
                    }
                )
            }
        }

    })
</script>
</body>
</html>